package com.zs.http;

import java.io.*;

/*
 * @description: 接收请求并初始化
 * @author ZC
 * @date: 2021/10/8 15:17
 */
public class Request {
    private String uri;
    private String method;

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Request(InputStream inputStream) {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
            //http请求第一行为请求URI和
            String[] str = bufferedReader.readLine().split(" ");
            this.uri = str[1];
            this.method = str[0];
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
